#include <iostream>
#include <string>
using namespace std;


int main(){
	string s,num="";
	char which='1';
	bool have_n=false;
	int ans=1;
	cin>>s;
	s += "+";
	for(int i=0;i<s.length();i++){
		char l=s[i];
		if(l == '*'  &&  num == "0"){
			while(s[i] != '+'){ i++; }
			num = "";
		}
		else if(l == '*'){
			i += 2;
			num = "";
		}
		else if(l == '^'){
			i++;
		}
		else if(l == '+'){
			if(num == "0"){
				num = "";
				continue;
			}
			have_n = true;
			int ans_l=0;
			ans_l = num[0]-'0';
			if(num.length() == 2) ans_l = ans_l*10+(num[1]-'0');
			if(ans_l > ans) ans = ans_l;
			num = "";
		}
		else{
			num += l;
		}
	}
	if(have_n){
		if(ans == 1) cout<<"O(n)";
		else cout<<"O(n^"<<ans<<")";
	}
	else{
		cout<<"O(1)";
	}
	return 0;
}
